#include<stdio.h>
#include<math.h>

int isprime(int x)
{
	int back=1;
	int i;
	if(x==1||(x%2==0&&x!=2)) back=0;
	for(i=3;i<=sqrt((double)x);i+=2){
		if(x%i==0){
			back=0;
			break;
		}
	}
	return back;
} 
int main()
{
	int sum=0,p,sign=2,sum2=0;
	scanf("%d",&p);
	for(;sum<p+10;sign++){
		if(isprime(sign)==1){
			sum++;
			if(sum>=p) sum2+=sign;
		} 
	}
	printf("%d",sum2);
	return 0;
}
